$OpenBSD: patch-cherokee_handler_streaming_c,v 1.2 2013/01/26 12:47:44 brad Exp $

Update for newer FFmpeg API.

--- cherokee/handler_streaming.c.orig	Fri Jan 18 03:22:41 2013
+++ cherokee/handler_streaming.c	Fri Jan 18 03:39:40 2013
@@ -110,10 +110,6 @@ cherokee_handler_streaming_free (cherokee_handler_stre
 		cherokee_handler_file_free (hdl->handler_file);
 	}
 
-	if (hdl->avformat != NULL) {
-		av_close_input_file (hdl->avformat);
-	}
-
 	cherokee_buffer_mrproper (&hdl->local_file);
 	return ret_ok;
 }
@@ -312,14 +308,14 @@ open_media_file (cherokee_handler_streaming_t *hdl)
 
 	/* Open the media stream
 	 */
-	re = av_open_input_file (&hdl->avformat, hdl->local_file.buf, NULL, 0, NULL);
+	re = avformat_open_input (&hdl->avformat, hdl->local_file.buf, NULL, NULL);
 	if (re != 0) {
 		goto error;
 	}
 
 	/* Read the info
 	 */
-	re = av_find_stream_info (hdl->avformat);
+	re = avformat_find_stream_info (hdl->avformat, NULL);
 	if (re < 0) {
 		goto error;
 	}
@@ -327,7 +323,7 @@ open_media_file (cherokee_handler_streaming_t *hdl)
 	return ret_ok;
 error:
 	if (hdl->avformat != NULL) {
-		av_close_input_file (hdl->avformat);
+		avformat_close_input (&hdl->avformat);
 		hdl->avformat = NULL;
 	}
 
@@ -380,7 +376,7 @@ set_auto_rate (cherokee_handler_streaming_t *hdl)
 	if (likely (secs > 0)) {
 		long tmp;
 
-		tmp = (hdl->avformat->file_size / secs);
+		tmp = (hdl->handler_file->info->st_size / secs);
 		if (tmp > rate) {
 			rate = tmp;
 			TRACE(ENTRIES, "New rate: %d bytes/s\n", rate);
@@ -471,7 +467,7 @@ cherokee_handler_streaming_init (cherokee_handler_stre
 
 		ret = seek_mp3 (hdl);
 		if (unlikely (ret != ret_ok)) {
-			return ret_error;
+			goto out;
 		}
 	}
 
@@ -480,6 +476,13 @@ cherokee_handler_streaming_init (cherokee_handler_stre
 	if (props->auto_rate) {
 		set_auto_rate (hdl);
 	}
+
+out:
+	/* Close our ffmpeg handle, all information has been gathered
+	 */
+        if (hdl->avformat != NULL) {
+                avformat_close_input (&hdl->avformat);
+        }
 
 	return ret_ok;
 }
